﻿/*
 * NetMessageDef.h
 */
#include <gdk/core/Types.h>
#include <gdk/core/Message.h>
#include <gdk/core/Buffer.h>


namespace simple
{


//**************************************************
#undef DECLARE_SIMPLE_MESSAGE_BEGIN
#undef DECLARE_SIMPLE_MESSAGE_MEMBER
#undef DECLARE_SIMPLE_MESSAGE_INIT
#undef DECLARE_SIMPLE_MESSAGE_END


//**************************************************
#if defined(IMPLEMENT_SIMPLE_MESSAGE_MTBL)

#	define DECLARE_SIMPLE_MESSAGE_BEGIN(className, baseClass) \
			IMPLEMENT_RT_CREATOR(className)\
			IMPLEMENT_MTBL_BEGIN(className)\
			IMPLEMENT_MTBL_SUPPER(baseClass)

#	define DECLARE_SIMPLE_MESSAGE_MEMBER(type, name) \
			IMPLEMENT_MTBL_MEMBER(name)

#	define DECLARE_SIMPLE_MESSAGE_INIT(name, value)

#	define DECLARE_SIMPLE_MESSAGE_END() \
			IMPLEMENT_MTBL_END()


//**************************************************
#elif defined(IMPLEMENT_SIMPLE_MESSAGE_PROPERTY)

#	define DECLARE_SIMPLE_MESSAGE_BEGIN(className, baseClass) \
			REGISTER_PROPERTY_CONVERTER_OBJECT(className)\
			IMPLEMENT_PROPERTY_BEGIN1(className, baseClass)

#	define DECLARE_SIMPLE_MESSAGE_MEMBER(type, name) \
			IMPLEMENT_PROPERTY_ATTRIBUTE(name, __TEXT__(#name))

#	define DECLARE_SIMPLE_MESSAGE_INIT(name, value)

#	define DECLARE_SIMPLE_MESSAGE_END() \
			IMPLEMENT_PROPERTY_END()


//**************************************************
#elif defined(IMPLEMENT_SIMPLE_MESSAGE_INIT)

#	define DECLARE_SIMPLE_MESSAGE_BEGIN(className, baseClass) \
			className::className(void)\
				: baseClass()

#	define DECLARE_SIMPLE_MESSAGE_MEMBER(type, name) 

#	define DECLARE_SIMPLE_MESSAGE_INIT(name, value) \
				, name(value)

#	define DECLARE_SIMPLE_MESSAGE_END() \
			{}


//**************************************************
#elif defined(REGISTER_SIMPLE_MESSAGE)

#	define DECLARE_SIMPLE_MESSAGE_BEGIN(className, baseClass) \
			REGISTER_RT_CREATOR(className)\
			REGISTER_PROPERTY(className)

#	define DECLARE_SIMPLE_MESSAGE_MEMBER(type, name) 

#	define DECLARE_SIMPLE_MESSAGE_INIT(name, value)

#	define DECLARE_SIMPLE_MESSAGE_END() 


//**************************************************
#else


	//---------------------------------------------
#	define DECLARE_SIMPLE_MESSAGE_BEGIN(className,baseClass) \
			typedef gdk::Unknown::Handle_T<class className> className##Ptr;\
			class GDK_SIMPLE_EXPORT className : public baseClass\
			{\
				DECLARE_CLASS_HANDLE(className)\
				DECLARE_CLASS_INSTANCE(className)\
				DECLARE_CLASS_SERIALIZE(className)\
				DECLARE_RT_CREATOR(className)\
				DECLARE_PROPERTY(className)\
				DECLARE_MTBL(className)\
				DECLARE_MESSAGE_PARSE(className)\
			private:\
				className(void);\
			public:

#	define DECLARE_SIMPLE_MESSAGE_MEMBER(type, name) \
				type name;

#	define DECLARE_SIMPLE_MESSAGE_END() \
			};


//**************************************************
#endif


//=====================================================
DECLARE_SIMPLE_MESSAGE_BEGIN(SimplePackage, gdk::Message)
	DECLARE_SIMPLE_MESSAGE_MEMBER(gdk::Buffer, data)
DECLARE_SIMPLE_MESSAGE_END()

DECLARE_SIMPLE_MESSAGE_BEGIN(SimplePackage2, gdk::Message)
	DECLARE_SIMPLE_MESSAGE_MEMBER(gdk::Varint, origLen)
	DECLARE_SIMPLE_MESSAGE_MEMBER(gdk::Buffer, data)
DECLARE_SIMPLE_MESSAGE_END()


} //namespace gdk

